<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/js/js/vue.js"></script>
    <script src="/js/js/jquery.js"></script>
</head>
<body>
    <div id="app">
        <h1>城市编码{{city}}</h1>
        <!-- <input type="text" v-model.lazy="city"> -->
        <div>
            <select name="" v-model.lazy="city" id="">
                <option value="430300">湖南</option>
                <option value="430300">湖南</option>
                <option value="430300">湖南</option>
                <option value="430300">湖南</option>
           </select>
       </div>
        <h3>城市:{{c}}<br> 天气:{{a}} <br>温度:{{b}}</h3>
    </div>
    <script>
        var vm=new Vue({
            el:"#app",
            data:{
                city:'',
                a:'',
                b:'',
                c:''
            },
            methods:{
                getInfo(){
                    let url="https://restapi.amap.com/v3/weather/weatherInfo?city="+this.city+"&key=878e50bc7eec89038d6747ff944b0d7e";
                    $.get(url,(ret)=>{
                        this.a=ret.lives[0].weather;
                        this.b=ret.lives[0].temperature;
                        this.c=ret.lives[0].province;
                    })
                }
            },
            watch:{
                city(newv,oldv){
                    console.log("新----旧",newv,oldv);
                    this.getInfo();
                }
            },
            computed:{

            }
        })
    </script>
</body>
<html>